﻿using System;
using fastCSharp;

namespace diantou.web.management
{
    /// <summary>
    /// 教程集合
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class tutorialList : permissionView<tutorialList>
    {
        /// <summary>
        /// 教程集合
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private tutorial.userTutorial[] tutorials;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        private bool loadView(int page, int userId)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0)
            {
                diantou.dataAccess.tutorial[] values = diantou.dataAccess.clientCache.Tutorial.Get(diantou.dataAccess.tcpCall.tutorial.getIds(userId, pageInfo.Size = 40, pageInfo.Page = page, currentUserId, out pageInfo.Count));
                if (currentUser.Permission != dataModel.user.permission.Admin)
                {
                    foreach (diantou.dataAccess.tutorial value in values) value.BrowseCount = 0;
                }
                tutorials = values.getArray(value => new tutorial.userTutorial { Tutorial = value, User = currentUser });
                return true;
            }
            AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = currentUser.Path.NewFocus });
            return false;
        }
    }
}
